package dao.hibernate;

import dao.common.ImageManager;
import models.shop.Image;

import java.util.List;

public class ImageManagerHB implements ImageManager {
    public void save(Image image) {
        image.save();
    }

    public Image create(String path, String md5) {
        Image image = new Image();
        image.filePath = path;
        image.md5 = md5;
        save(image);
        return image;
    }

    public List<Image> listByProductId(int productId) {
        return Image.find("byProductId", productId).fetch();
    }

    public Image getById(int imageId) {
        return Image.findById(imageId);
    }
}
